//mine.js
//获取应用实例
var app = getApp()
Page({
  data:{
  	userInfo:[],
    imgSrc:'',
    scanResult:'',
    loc:[]
  },
  onLoad: function () {
    var that = this;
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  },
  //location
  getLocation: function(){
    wx.getLocation({
      type: 'gcj02', //返回可以用于wx.openLocation的经纬度
      success: function(res) {
        var latitude = res.latitude
        var longitude = res.longitude
        wx.openLocation({
          latitude: latitude,
          longitude: longitude,
          scale: 28,
          
        })
      }
    })
  },
  //scan
  scanCode: function(){
    var that = this;
    wx.scanCode({
      success: (res) => {
        that.setData({
          scanResult : res.result
        })
      }
    })
  },
  //上传图片显示
  choseImagea: function() {
    var that = this;
    wx.chooseImage({
      count: 3, 
      sizeType: ['original', 'compressed'], 
      sourceType: ['album', 'camera'], 
      success: function (res) {
        wx.getImageInfo({
          src: res.tempFilePaths[0],
          success: function (res) {
            console.log(res.width);
            console.log(res.height);
            console.log(res.path);
           // that.imgSrc = res.path;
            that.setData({ 
              imgSrc:res.path 
            }) 
          }
        })
      }
    })
  }
})
